package com.atguigu.gulimall.order.vo;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Data
public class OrderConfirmVo {

    //收获地址
    private List<MemberAddressVo> address;

    //所有选中的购物项
    private List<OrderItemVo> items;

    //发票信息。。。这里不做了

    //优惠券信息 就用会员系统中积分来来代替
    private Integer integration;

    private String orderToken;

    private Map<Long,Boolean> stocks;

    public BigDecimal getTotal() {
        //订单总价
        BigDecimal total = BigDecimal.ZERO;

        for (OrderItemVo item : items) {
            total = total.add(item.getPrice().multiply(BigDecimal.valueOf(item.getCount())));
        }
        return total;
    }

    private Integer count;

    public Integer getCount() {
        int count = 0;
        for (OrderItemVo item : items) {
            count = count + item.getCount();
        }
        return count;
    }

    public BigDecimal getPayPrice() {
        return getTotal(); //优惠先不考虑了
    }

}
